﻿using System;
using System.Collections;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;
using System.Windows;

namespace ProjectEdificio
{

    public class SendEmail
    {
        private MailMessage msg = null;

        public SendEmail()
        {
            
        }

        public void SendEmailConDatos(Usuario u)
        {

            msg = new MailMessage();
            msg.To.Add(u.Email);
            msg.From = new MailAddress("verydificultpro@gmail.com", "User", System.Text.Encoding.UTF8);
            msg.Subject = "Recuperar Contraseña";
            msg.SubjectEncoding = System.Text.Encoding.UTF8;
            msg.Body = "Buenas "+u.User+" tu contraseña es "+u.Pass+". Cualquier duda que tengas contesta este mail y te responderemos a la brevedad. Atte. Administrador de Very Dificult PRO";
            msg.BodyEncoding = System.Text.Encoding.UTF8;
            msg.IsBodyHtml = false;

            SmtpClient client = new SmtpClient();
            client.Credentials = new System.Net.NetworkCredential("verydificultpro@gmail.com", "verydificult2013");
            client.Port = 587;
            client.Host = "smtp.gmail.com";
            client.EnableSsl = true;
            try
            {
                client.Send(msg);
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                MessageBox.Show(ex.Message);
                Console.ReadLine();
            }
        }


        public void SendError(String error)
        {
            msg = new MailMessage();
            msg.To.Add("verydificultpro@gmail.com");
            msg.From = new MailAddress("verydificultpro@gmail.com", "User", System.Text.Encoding.UTF8);
            msg.Subject = "Error";
            msg.SubjectEncoding = System.Text.Encoding.UTF8;
            msg.Body = error;
            msg.BodyEncoding = System.Text.Encoding.UTF8;
            msg.IsBodyHtml = false;

            SmtpClient client = new SmtpClient();
            client.Credentials = new System.Net.NetworkCredential("verydificultpro@gmail.com", "verydificult2013");
            client.Port = 587;
            client.Host = "smtp.gmail.com";
            client.EnableSsl = true;
            try
            {
                client.Send(msg);
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                MessageBox.Show(ex.Message);
                Console.ReadLine();
            }
        }

    }
}